﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using zielonka.co.uk.test.framework.time;

namespace zielonka.co.uk.extensions.system.tests
{
    [TestClass]
    public class ByteFromStringTests
    {
        [TestMethod]
        public void ReturnsTheCorrectByteArrayFromAString()
        {
            byte[] expected = new byte[32];
            Array.Copy(Encoding.Unicode.GetBytes("5QCeDfJYfcO4QTsF50P66unIZKrvuRge"), expected, 32);

            byte[] actual = new byte[32];
            actual = actual.FromString("5QCeDfJYfcO4QTsF50P66unIZKrvuRge");
            
            //compare each byte
            for(int i =0; i<actual.Length; i++)
            {
                Assert.AreEqual(expected[i],actual[i]);
            }            
        }

        [TestMethod]
        public void ReturnsTheCorrectByteArrayFromAStringWhenTheByteArrayIsNull()
        {
            byte[] expected = new byte[32];
            Array.Copy(Encoding.Unicode.GetBytes("5QCeDfJYfcO4QTsF50P66unIZKrvuRge"), expected, 32);

            byte[] actual = new byte[]{};
            actual = actual.FromString("5QCeDfJYfcO4QTsF50P66unIZKrvuRge");

            Assert.IsTrue(actual.Length>10);
            //compare each byte
            for (int i = 0; i < actual.Length; i++)
            {
                Assert.AreEqual(expected[i], actual[i]);
            }
        }
    }
}
